import { searchHistory } from '../../api/navigation'
const app = getApp()
Page({
  data: {
    options: [
      { text: '备课', value: 'design' },
      { text: '教研', value: 'activity' },
      { text: '课程', value: 'live' },
      { text: '平台素材', value: 'material' },
    ],
    searchType: 'design',
    list: [],
  },
  onLoad: function (options) {
  },
  onShow: function() {
    this.init()
  },
  onScroll(event) {

  },
  init() {
    searchHistory().then(res => {
      this.setData({
        list: res
      })
    })
  },
  onSearch(e) {
    if (!e.detail) {
      wx.showToast({
        title: '请输入关键字',
        icon: 'none',
        duration: 2000
      })
      return false;
    }
    wx.navigateTo({
      // url: '/packageA/pages/searchResult/searchResult?keyword=' + e.detail + '&type=' + this.data.searchType
      url: '/packageA/pages/searchResult/searchResult?keyword=' + e.detail
    })
  },
  toSearch(e) {
    wx.navigateTo({
      url: '/packageA/pages/searchResult/searchResult?keyword=' + e.currentTarget.dataset.name
    })
  }
})
